﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="user_reg.aspx.cs" Inherits="user_user_reg" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>用户注册</title>
    <link href="../css/ecrm03.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="Sun, 6 Mar 2005 01:00:00 GMT" />
    <style type="text/css">
    .hint {display:none;}
    .ct {width:300px;border:1px solid #DCF5D5;background:#eef9eb;padding:5px 0 5px 5px;}
    </style><link href="../css/douban12958.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../js/jquery0905.js"></script>
    <script type="text/javascript" src="../js/douban12958.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table width="900" border="0" cellpadding="0" cellspacing="0" align="center">
            <tr>
                <td>
                    <div id="nav"><a class="now" href="../index.aspx"><span>首页</span></a></div>
                    <div class="clear"></div><div id="status"><div id="subnav"></div><span class="pl">&nbsp;</span></div><br />
                    <div><h1>快速注册用户</h1></div>


        <div style="padding-left:50px;">
            <span class="m">你的公司Email地址:<br /><asp:TextBox ID="email" runat="server"></asp:TextBox></span><span id="e_hint" class="attn hint">请输入Email地址</span><br />
            <div id="e_correct"><SPAN class="pl">用此邮箱接收确认邮件才能完成注册。</SPAN></div><br />
            <span class="m">给自己设一个密码:<br /><asp:TextBox ID="password" runat="server" TextMode="Password"></asp:TextBox></span><span id="p_hint" class="attn hint">请输入密码</span><br /><SPAN class="pl">最少4个字符，请使用英文字母（区分大小写）、符号或数字。</SPAN> <br /><br />
            <span class="m">再输一遍密码:<br /><asp:TextBox ID="password2" runat="server" TextMode="Password"></asp:TextBox></span><span id="p2_hint" class="attn hint">密码不一致</span><br /><SPAN class="pl">重复输入一遍密码。</SPAN><br /><br />
            <span class="m">自己的真实姓名:<br /><asp:TextBox ID="name" runat="server"></asp:TextBox></span><span id="n_hint" class="attn hint">请输入你的姓名</span><br /><SPAN class="pl">中、英文均可。</SPAN><br /><br />
            <asp:Button ID="btnSubmit" runat="server" Text="完成注册" Width="86px" OnClick="btnSubmit_Click" /><font style="font-size: 9pt; color: red;"><asp:Literal ID="msg" runat="server"></asp:Literal></font>
        </div>
        <script type="text/javascript">
            /*<![CDATA[*/
            var email=$("#email"),e_hint=$("#e_hint"),e_correct=$("#e_correct");
            var passwd=$("#password"),p_hint=$("#p_hint");
            var passwd2=$("#password2"),p2_hint=$("#p2_hint");
            var name=$("#name"),n_hint=$("#n_hint");

            var email_reg = /^[_\.0-9a-zA-Z+-]+@([0-9a-zA-Z]+[0-9a-zA-Z-]*\.)+[a-zA-Z]{2,4}$/;
            var passwd_reg = /^(\w){4,20}/ ;
            var email_list = new Array('163.com','126.com', '139.com', '188.com', '2008.china.com', '2008.sina.com', '21cn.com', '263.net', 'china.com', 'chinaren.com', 'citiz.net', 'eyou.com', 'foxmail.com', 'gmail.com', 'hongkong.com', 'hotmail.com', 'live.cn', 'live.com', 'mail.china.com', 'msn.com', 'my3ia.sina.com', 'qq.com', 'sina.cn', 'sina.com', 'sina.com.cn', 'sogou.com', 'sohu.com', 'tom.com', 'vip.163.com', 'vip.qq.com', 'vip.sina.com', 'vip.sohu.com', 'vip.tom.com', 'yahoo.cn', 'yahoo.com', 'yahoo.com.cn', 'yahoo.com.hk', 'yahoo.com.tw', 'yeah.net');

            function DPA(s1, s2){ 
                var m = new Array();
                var i, j;
                for(i=0; i < s1.length + 1; i++) m[i] = new Array(); // i.e. 2-D array

                m[0][0] = 0; // boundary conditions

                for(j=1; j <= s2.length; j++)
                    m[0][j] = m[0][j-1]-0 + 1; // boundary conditions

                for(i=1; i <= s1.length; i++)                            // outer loop
                { 
                    m[i][0] = m[i-1][0]-0 + 1; // boundary conditions

                    for(j=1; j <= s2.length; j++)                         // inner loop
                    { 
                        var diag = m[i-1][j-1];
                        if( s1.charAt(i-1) != s2.charAt(j-1) ) diag++;

                        m[i][j] = Math.min( diag,               // match or change
                        Math.min( m[i-1][j]-0 + 1,    // deletion
                        m[i][j-1]-0 + 1 ) ) // insertion
                    }//for j
                }//for i
               return m[s1.length][s2.length];
            }

            var email_value = '';
            var e_name = '';
            var e_domain = ''
            var e_tip_on = 0;

            function e_back(){
                e_correct.html('<span class="pl">用此邮箱接收确认邮件才能完成注册。</span>');
                passwd.focus();
                e_tip_on = 0;
            }
            function e_set(){
                email.attr('value', e_name + '@' + e_domain);
                e_hint.fadeOut();    
                e_back();
            }
            function get_like(s){
                r = 0;
                v = s.split('@');
                domain = v[1];
                e_name = v[0];
                dis = domain.length;
                for (k=0; k < email_list.length; k++){
                    e = email_list[k];
                    d = DPA(domain, e);
                    if (d < dis){
                        dis = d;
                        e_domain = e;
                    }
                }
                if(dis && dis < 4){ 
                    r = 1;
                }
                return r;
            };

            function isChinese(name) 
            { 
                var re = /[^\u4e00-\u9fa5]/; 
                if(re.test(name)) return false; 
                return true; 
            } 

            function check_email(like){
                e_hint.fadeOut();    
                r = 1;
                s = email.attr('value'); 
                if (!s){
                    r = 0;
                    e_hint.fadeIn();    
                }else if (!email_reg.exec(s)){
                    e_hint.html('请输入正确的Email地址');
                    e_hint.fadeIn();    
                    r = 0;
                }else{
                    if (like && get_like(s)){
                        as = ' <a id="yes_but" href="javascript:void(0)" onclick="e_set()">是</a>／<a href="javascript:void(0)" onclick="e_back()">不是</a>'
                        e_correct.html('<div class="ct"><span class="pl">你是否要输入' + e_name + '@</span>' + e_domain + as + '</div>');
                        $("#yes_but").focus();
                        e_tip_on = 1;
                    }else{
                        e_hint.fadeOut();    
                        var url = '/j/register/is_registered?email='+s;
                        $.getJSON(url, function(j){
                            if (j.ok){
                                e_hint.html('该Email已经注册过');
                                e_hint.fadeIn();    
                                email_value = s;
                                r = 0;
                            }
                            else{
                                r = 1;     
                            }
                        })
                    }
                }
                email_value = email.attr('value');
                return r
            };
            function check_password(){
                r = 1;
                if (e_tip_on) return r;
                s = passwd.attr('value'); 
                if (!s){
                    r = 0;
                }else if(s.length < 4){
                    p_hint.html('最少4个字符');
                    r = 0;
                }else if (!passwd_reg.exec(s)){
                    p_hint.html('请使用英文字母、符号或数字');
                    r = 0;
                }
                if (r){
                    p_hint.fadeOut();    
                }else{
                    p_hint.fadeIn();    
                }
                return r
            };
            function check_password2(){
                r=1;
                s=passwd2.attr('value');
                if(s!=passwd.attr('value'))
                {
                    p2_hint.html('密码不一致');
                    r=0;
                }
                if (r){
                    p2_hint.fadeOut();    
                }else{
                    p2_hint.fadeIn();    
                }
                return r
            }
            function check_name(){
                r = 1;
                s = name.attr('value'); 
                if (!s){
                    n_hint.fadeIn();    
                    r = 0;
                }else{
                    n_hint.fadeOut();    
                }
                return r
            };
            email.blur(function(){
                check_email(1);
            });
            name.blur(function(){
                check_name();
            });
            passwd.blur(check_password);
            passwd2.blur(check_password2);

            function chk()
            {
                r1 = check_email(0);
                
                var stremail=new String($('#email').val());
                if((stremail.indexOf('cnap.com.cn')==-1)&&(stremail.indexOf('autocarcn.com')==-1))
                {
                    alert('必须使用cnap.com.cn或autocarcn.com的邮箱注册！');
                    return false;    
                }
                
                r2 = check_password();
                r4 = check_password2();
                r3 = check_name();
                
                var myname=$("#name").val();
                if(!isChinese(myname))
                {
                    alert('必须使用中文名字注册！');
                    return false;
                }
                
                if (r1 && r2 && r3 && r4){
                    return;
                }else{
                    return false;
                }
            }
            /*]]>*/
        </script>
                    <br />
                    <div style="border-bottom: darkgray 1px dashed;"></div>
                    <span class="bottomfont">&copy;EasyCRM 2008-2009 汽车中国</span>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
